package com.bitcat.firstapp.demo.component

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.bitcat.firstapp.R
import com.bitcat.firstapp.databinding.ActivityCheckBoxDemoBinding
import com.bitcat.firstapp.utils.ToastUtil
import es.dmoral.toasty.Toasty

class CheckBoxDemoActivity : AppCompatActivity() {

    private val binding: ActivityCheckBoxDemoBinding by lazy {
        ActivityCheckBoxDemoBinding.inflate(layoutInflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(binding.root)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        binding.checkBoxReading.setOnCheckedChangeListener { buttonView, isChecked ->
           Toasty.info(this,"阅读：$isChecked").show()
        }
        binding.checkBoxMusic.setOnCheckedChangeListener { buttonView, isChecked ->
            ToastUtil.showToast("音乐：$isChecked")
        }
        binding.checkBoxSports.setOnCheckedChangeListener { buttonView, isChecked ->
            ToastUtil.showToast("运动：$isChecked")
        }
        binding.checkBoxTravel.setOnCheckedChangeListener { buttonView, isChecked ->
            ToastUtil.showToast("旅行：$isChecked")
        }
    }
}